package org.example.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.demo.entity.ApplicationData;
import org.example.demo.entity.User;
import org.example.demo.result.PageResult;
import org.example.demo.service.ApplicationDataService;
import org.example.demo.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


/*
   处理申请书审核数据
 */
@RestController
@RequestMapping("/ApplicationData")
public class ApplicationDataController {

    @Autowired
    ApplicationDataService applicationDataService;


    /**
     * 更新申请书审核数据
     * @param applicationData
     * @return
     */
    @PutMapping("/update")
    public AjaxResult update(@RequestBody ApplicationData applicationData) {
        // 更新数据
        applicationDataService.update(applicationData);

        return AjaxResult.success();
    }


//    @GetMapping("/page")
//    public AjaxResult page(@RequestBody ApplicationData applicationData, Integer page, Integer pageSize) {
//        Page<ApplicationData> page1 = new Page<>();
//        page1.setCurrent(page);
//        page1.setSize(pageSize);
//        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
//        //根据用户名、账号查询，注意是模糊查询
//        Page<User> selectApplicationData = ApplicationDataService.page(page1, queryWrapper.lambda()
//                .like(null != applicationData.getApplicationId() && !user.getAccount().isEmpty(), User::getAccount, user.getAccount())
//                .like(null != user.getName() && !user.getName().isEmpty(), User::getName, user.getName())
//                .eq(user.getRole()!=null&&!user.getRole().isEmpty(),User::getRole,user.getRole())
//                .eq(user.getPoliticalStatus()!=null&&!user.getPoliticalStatus().isEmpty(),User::getPoliticalStatus,user.getPoliticalStatus())
//                .orderByDesc(User::getCreateTime)
//        );
//
//        Map<String, Object> retMap = new HashMap<>();
//        retMap.put("page", selectUser);
//        return AjaxResult.success(retMap);
//    }


}
